package com.show.service.emp;

import com.show.util.QueryUtil;
import com.show.dao.sys_emp.EmpOrgRespository;
import com.show.dto.sys_emp.SysEmpOrg;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.transaction.Transactional;
import java.util.List;

/**
 * Created by yxd on 2018/2/5.
 */
@Service
@Transactional
public class EmpOrgService {

    @Autowired
    private EmpOrgRespository empOrgRespository;
    @Autowired
    private QueryUtil queryUtil;

    /**
     * 添加人员--部门
     *@param SysEmpOrg
     * @author yxd
     * @time 2018年2月5日
     */
    public void save(SysEmpOrg info){
        empOrgRespository.saveAndFlush(info);
    }

    /**
     * 根据empId查询所在部门
     * @param empId
     * @author 王硕
     * @return
     */
    public List<SysEmpOrg> getOrgByempId(Integer empId){
        String sql = "SELECT * FROM `sys_emp_org`  where emp_id  = " + empId;
        return queryUtil.query(sql,SysEmpOrg.class);
    }
}
